import wx
from MainForm import MainForm
#we need these imports here to let pyinstaller know that we want setupargs1
from wx.lib.pubsub import setuparg1
from wx.lib.pubsub import pub

from Setting import Setting
from DataManager import DataManager
from SimpleDialogs import DialogChooseDB

# Run the program
if __name__ == "__main__":

    #print(pub.VERSION_STR)
    #print(pub.getMsgProtocol())
    app = wx.App(redirect=True, filename='log.log')
    Setting.init()
    #show db selecting dialog
    retl = []
    dlg = DialogChooseDB(retl)
    ret = dlg.ShowModal()
    dlg.Destroy()
    if ret == 0:
        #data must be initialized first
        DataManager.init(retl[0])
        
        #app.RedirectStdio('log.log')
    
        frame = MainForm(retl[0])
        app.MainLoop()
